/*
 * Copyright (c) 2006, 2022, webrx.cn All rights reserved.
 *
 */

import java.util.concurrent.TimeUnit;

/**
 * <p>Project: jse2204 - VolatileDemo
 * <p>Powered by webrx On 2022-09-30 14:07:59
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class VolatileDemo {
    volatile boolean f = true;

    public void m(){
        System.out.println("v start");
        while(f){
            //System.out.printf("%tF %<tT%n",System.currentTimeMillis());
        }
        System.out.println("v end");
    }


    public static void main(String[] args) {
        VolatileDemo v = new VolatileDemo();

        //v线程
        new Thread(v::m,"v").start();

        //main线程
        try{
            TimeUnit.SECONDS.sleep(1);
        }catch(Exception e){
            e.printStackTrace();
        }
        v.f = false;
    }
}
